package cn.com.yusys.yusp.admin.web.rest;

import cn.com.yusys.yusp.admin.domain.AdminSmDataFilter;
import cn.com.yusys.yusp.admin.service.AdminSmDataFilterService;
import cn.com.yusys.yusp.commons.service.CommonService;
import cn.com.yusys.yusp.commons.web.rest.CommonResource;
import cn.com.yusys.yusp.commons.web.rest.dto.ResultDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @项目名称：yusp-admin
 * @类名称：AdminSmDataFilterResource @类描述：
 * @功能描述:数据权限过滤器rest
 * @创建人：liaoxd@yusys.com.cn @创建时间：2017-12-12 15:43 @修改备注：
 * @修改日期 修改人员 修改原因 -------- -------- ----------------------------------------
 * @version 1.0.0
 * @param <T>
 * @Copyright (c) 2017宇信科技-版权所有
 */
@RestController
@RequestMapping("/api/datafilter")
public class AdminSmDataFilterResource<T> extends CommonResource<AdminSmDataFilter, String> {

	@Autowired
	private AdminSmDataFilterService adminSmDataFilterService;

	private final Logger log = LoggerFactory.getLogger(AdminSmDataFilterResource.class);

	@Override
	protected CommonService getCommonService() {
		return this.adminSmDataFilterService;
	}

	/**
	 * @方法名称:deleteMult
	 * @方法描述:多个删除数据权限过滤器
	 * @参数与返回说明:
	 * @算法描述:
	 */
	@PostMapping("/deletes/{ids}")
	public ResultDto<Integer> deleteMult(@PathVariable String ids) {
		log.debug("REST request to delete Object : {}", ids);
		String[] id = ids.toString().split(",");
		int i;
		for (i = 0; i < id.length; i++) {
			adminSmDataFilterService.deletes(id[i]);
		}
		int result = i;
		return new ResultDto<Integer>(result);

	}

	/**
	 * @函数名称:update
	 * @函数描述:修改接口
	 * @参数与返回说明:
	 * @算法描述:
	 */
	@PostMapping("/updates")
	public ResultDto<Integer> updateSelective(@RequestBody AdminSmDataFilter t)
			throws Exception {
		log.debug("REST request to update Object : {}", t);

		int result = getCommonService().updateSelective(t);

		return new ResultDto<Integer>(result);
	}

}
